package com.fms.controllers.treasurer;

import home.HomePage;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import com.fms.dao.BKCashReceiptJournalDAO;
import com.fms.model.BKCashReceiptJournalModel;

public class BKCashReceiptJournalList extends WebPage {
	
	BKCashReceiptJournalDAO bkCrjDAO = new BKCashReceiptJournalDAO();
	
	public BKCashReceiptJournalList() throws IOException, SQLException
	{
		//Reader reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		//SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		
		add(new BookmarkablePageLink("home", TreasurerHome.class));
		add(new BookmarkablePageLink("logoutPage", HomePage.class));
		add(new BookmarkablePageLink("addSubsidiary", BKCashReceiptJournal.class));
		
		Form form = new Form("SubsidiaryListForm");
		
		List<BKCashReceiptJournalModel> list = (List<BKCashReceiptJournalModel>)bkCrjDAO.selectAll();
		
		ListView eachRecord = new ListView("eachRecord", list) {
			private static final long serialVersionUID = 1L;
			
			protected void populateItem(ListItem item) {
				final BKCashReceiptJournalModel bs = (BKCashReceiptJournalModel) item.getModelObject();
				//item.add(new CustomCheckBox("checkbox", new CustomCheckBoxModel(bl.getForm_id())));
				item.add(new Label("date", bs.getDate()));
				item.add(new Label("particulars", bs.getParticulars()));
				item.add(new Label("assessment", Float.toString(bs.getAssessment())));
				item.add(new Label("interest", Float.toString(bs.getInterest_deposits())));
				item.add(new Label("donations", Float.toString(bs.getDonation_solicitation())));
				item.add(new Label("fines", Float.toString(bs.getFines())));
				item.add(new Label("status", bs.getStatus()));
				
				//item.add(new Label("uploadedDate", bk.getDate_created()));
				//item.add(new Label("uploadedBy", bl.getUploader()));
			}
		};
		form.add(eachRecord);
		add(form);
	}
	
	public String getTitlePage(){
		return ("Financial Management System");
		
	}
	

}
